export class Layer {
    constructor(ctx, x, y) {
        this.grid = null;
        this.name = null;
        this.ctx = ctx;
        this.x = x;
        this.y = y;
    }

    setName(name) {
        this.name = name;
    }

    draw() {
        this.ctx.beginPath();
        this.ctx.strokeRect(this.x, this.y, 100, 100);
        this.ctx.closePath();
    }

    //由对象返回是否在这个坐标上，右键仿照photoshop 图层设计
    // 由点击坐标，转换到行列，然后转换到一维数组的下标
    // this.mycanvas.onmousedown = (e) => {
    //     var x = e.clientX;
    //     var y = e.clientY;
    // }
    // index = this.getCell(x, y)

    // getCell(x, y) {
    //列宽100 行高30
    //     const lie = Math.floor(Math.abs(x - this.padding) / 100)
    //     const hang = Math.floor(Math.abs(y - this.padding) / 30)
    //     const index = hang * this.column + lie
    //     return index;
    // }

}

export class LayerManager {
    constructor(canvas) {
        this.ui = [];
        this.layerList = [];
        this.canvas = canvas;
        // this.name = null;
    }

    addLayer(name, x, y) {
        // var layer1 = new Layer(this.canvas, x, y);
        // layer1.setName(name);
        // this.layerList.push(layer1);
    }

    removeLayer(name) {
        console.log("")
    }

    draw(index) {
        this.layerList.forEach(item => {
            item.draw();
        })
    }


    getLayerName(index) {
        return this.layerList[index].name;
    }

    getCount() {
        return this.layerList.length;
    }
}
